#!/usr/bin/env python
# encoding: utf-8
"""
test_atom_compact.py

Created by Dag Brattli on 2008-03-02.
Copyright (c) 2009 Dag Brattli. All rights reserved.
"""

import sys
import os
import logging

logging.basicConfig(level=logging.WARNING)

from elements import atom_compact as atom

def test_atom_compact(filename="tests/atom.xml"):
    data = open(filename).read()
    d = atom.Feed()
    d.from_string(data)
    
    x = d.to_dict()
    print x
    assert(x['feed']['title'] == "Example Feed")
    assert(x['feed']['entry'][0]['summary'] == "Some text.")
    
    d = atom.Feed()
    d.from_dict(x)
    
    print d.to_string()
    assert(d.title.text == "Example Feed")
    assert(d.entry[0].summary.text == "Some text.")

if __name__ == '__main__':
	test_atom_compact("atom.xml")

